NO-ISSUE: Fixes KubeletConfig API doc, adds tests and kubebuilder validation#2651
NO-ISSUE: Fixes KubeletConfig API doc, adds tests and kubebuilder validation#2651ngopalak-redhat wants to merge 2 commits intoopenshift:masterfrom
Conversation
|
Pipeline controller notification For optional jobs, comment This repository is configured in: LGTM mode |
|
Skipping CI for Draft Pull Request. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a YAML test suite for the KubeletConfig CRD covering onCreate and onUpdate scenarios (single-field, multi-field, and invalid-value cases). Adds two optional fields to KubeletConfigSpec: AutoSizingReserved (*bool) and LogLevel (*int32) with validation (0–10). Updates generated Swagger/docs and the CRD: clarifies kubeletConfig and machineConfigPoolSelector descriptions, expands logLevel and tlsSecurityProfile descriptions, and adds x-kubernetes-validations to restrict tlsSecurityProfile to Old and Intermediate. 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
|
Hello @ngopalak-redhat! Some important instructions when contributing to openshift/api: |
|
/test all |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
12dcb66 to
8e0b9d6
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@payload-manifests/crds/0000_80_machine-config_01_kubeletconfigs.crd.yaml`:
- Around line 118-123: The tlsSecurityProfile description in the KubeletConfig
CRD is inconsistent with the schema: the text claims "Only Old and Intermediate
profiles are supported; maximum minTLSVersion is VersionTLS12" while the schema
allows Modern and Custom (and VersionTLS13) because it relies on
configv1.TLSSecurityProfile which has no kubelet-specific restrictions; to fix,
either add explicit validation to the CRD (e.g., CEL rules or a validating
webhook) to reject profile.type values "Modern" and "Custom" and enforce max
minTLSVersion of "VersionTLS12", or update the tlsSecurityProfile description to
accurately reflect that the schema permits Modern and Custom and VersionTLS13 by
referencing configv1.TLSSecurityProfile semantics; locate and change the
tlsSecurityProfile block in the KubeletConfig CRD (symbol: tlsSecurityProfile,
resource: KubeletConfig) and implement one of the two options consistently
(validation rules if you want to forbid Modern/Custom, otherwise update the
descriptive text).
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to data retention organization setting
⛔ Files ignored due to path filters (2)
machineconfiguration/v1/zz_generated.crd-manifests/0000_80_machine-config_01_kubeletconfigs.crd.yamlis excluded by!**/zz_generated.crd-manifests/*machineconfiguration/v1/zz_generated.featuregated-crd-manifests/kubeletconfigs.machineconfiguration.openshift.io/AAA_ungated.yamlis excluded by!**/zz_generated.featuregated-crd-manifests/**
📒 Files selected for processing (4)
machineconfiguration/v1/tests/kubeletconfigs.machineconfiguration.openshift.io/KubeletConfigSpec.yamlmachineconfiguration/v1/types.gomachineconfiguration/v1/zz_generated.swagger_doc_generated.gopayload-manifests/crds/0000_80_machine-config_01_kubeletconfigs.crd.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
- machineconfiguration/v1/types.go
🔇 Additional comments (2)
machineconfiguration/v1/zz_generated.swagger_doc_generated.go (1)
216-223: Docs read well and are consistent with the CRD updates.
The KubeletConfigSpec descriptions are clear and actionable.machineconfiguration/v1/tests/kubeletconfigs.machineconfiguration.openshift.io/KubeletConfigSpec.yaml (1)
1-275: Solid coverage for create/update scenarios.
The matrix of single-field and combined updates looks thorough.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
payload-manifests/crds/0000_80_machine-config_01_kubeletconfigs.crd.yaml
Show resolved
Hide resolved
|
@ngopalak-redhat: This pull request explicitly references no jira issue. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
...onfiguration/v1/zz_generated.crd-manifests/0000_80_machine-config_01_kubeletconfigs.crd.yaml
Show resolved
Hide resolved
...nfiguration/v1/tests/kubeletconfigs.machineconfiguration.openshift.io/KubeletConfigSpec.yaml
Outdated
Show resolved
Hide resolved
saschagrunert
left a comment
There was a problem hiding this comment.
Thank you for the PR, I have a bunch of improvements sggested.
Please note that we need to add integration tests for the new validations.
8e0b9d6 to
b52d6d1
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@machineconfiguration/v1/types.go`:
- Around line 769-774: The CEL XValidation currently permits profiles without an
explicit type and thus allows Modern/Custom via embedded fields; update the
validation on TLSSecurityProfile to require that the type field is present and
equal to either "Old" or "Intermediate" (e.g. change the rule to require
has(self.type) && (self.type == 'Old' || self.type == 'Intermediate')), so
TLSSecurityProfile (the TLSSecurityProfile *configv1.TLSSecurityProfile field)
cannot be set to Modern/Custom without an explicit allowed type.
♻️ Duplicate comments (1)
payload-manifests/crds/0000_80_machine-config_01_kubeletconfigs.crd.yaml (1)
268-271: Keep the CRD validation in sync with the tightened TLS rule.Same concern as in
machineconfiguration/v1/types.go: regenerate this CRD after tightening the CEL rule so missingtypecan’t bypass the restriction.
🧹 Nitpick comments (1)
machineconfiguration/v1/tests/kubeletconfigs.machineconfiguration.openshift.io/KubeletConfigSpec.yaml (1)
173-220: Add a negative case fortlsSecurityProfilewithouttype.This will lock in the stricter validation and prevent bypasses if the object is provided without a
type.🧪 Suggested test case
@@ - name: Should reject tlsSecurityProfile with Custom type initial: | apiVersion: machineconfiguration.openshift.io/v1 kind: KubeletConfig spec: tlsSecurityProfile: type: Custom custom: ciphers: - ECDHE-ECDSA-AES128-GCM-SHA256 minTLSVersion: VersionTLS12 expectedError: "only Old and Intermediate TLS profiles are supported for kubelet" + - name: Should reject tlsSecurityProfile without type + initial: | + apiVersion: machineconfiguration.openshift.io/v1 + kind: KubeletConfig + spec: + tlsSecurityProfile: + custom: + ciphers: + - ECDHE-ECDSA-AES128-GCM-SHA256 + minTLSVersion: VersionTLS12 + expectedError: "only Old and Intermediate TLS profiles are supported for kubelet"
b52d6d1 to
cb2ecfa
Compare
@saschagrunert I made the code changes as suggested. I also added the validations and tests to machineconfiguration/v1/tests/kubeletconfigs.machineconfiguration.openshift.io/KubeletConfigSpec.yaml. Are these the integration tests you were referring to? |
...nfiguration/v1/tests/kubeletconfigs.machineconfiguration.openshift.io/KubeletConfigSpec.yaml
Outdated
Show resolved
Hide resolved
...nfiguration/v1/tests/kubeletconfigs.machineconfiguration.openshift.io/KubeletConfigSpec.yaml
Outdated
Show resolved
Hide resolved
...nfiguration/v1/tests/kubeletconfigs.machineconfiguration.openshift.io/KubeletConfigSpec.yaml
Outdated
Show resolved
Hide resolved
...nfiguration/v1/tests/kubeletconfigs.machineconfiguration.openshift.io/KubeletConfigSpec.yaml
Outdated
Show resolved
Hide resolved
...nfiguration/v1/tests/kubeletconfigs.machineconfiguration.openshift.io/KubeletConfigSpec.yaml
Outdated
Show resolved
Hide resolved
...nfiguration/v1/tests/kubeletconfigs.machineconfiguration.openshift.io/KubeletConfigSpec.yaml
Outdated
Show resolved
Hide resolved
33fda82 to
1b89d6b
Compare
|
@saschagrunert Thanks for the review. I have addressed your comments. Could you take another look? I also replied to the specific discussion here: #2651 (comment) |
...nfiguration/v1/tests/kubeletconfigs.machineconfiguration.openshift.io/KubeletConfigSpec.yaml
Show resolved
Hide resolved
d174e51 to
abafcac
Compare
...nfiguration/v1/tests/kubeletconfigs.machineconfiguration.openshift.io/KubeletConfigSpec.yaml
Outdated
Show resolved
Hide resolved
...nfiguration/v1/tests/kubeletconfigs.machineconfiguration.openshift.io/KubeletConfigSpec.yaml
Show resolved
Hide resolved
…PI doc and adds tests
abafcac to
13eaa95
Compare
There was a problem hiding this comment.
Thanks for iterating on this. The PR is in good shape. The documentation improvements follow the API conventions well and the ratcheting tests properly cover the upgrade path.
The verify-crdify failure is expected since this PR intentionally tightens logLevel bounds and adds a CEL rule on tlsSecurityProfile. We can /override once the inline comments are addressed.
Putting it into shadow review complete since the required changes are already suggested.
...nfiguration/v1/tests/kubeletconfigs.machineconfiguration.openshift.io/KubeletConfigSpec.yaml
Show resolved
Hide resolved
everettraven
left a comment
There was a problem hiding this comment.
A couple comments to add to @saschagrunert 's review but overall this looks pretty good.
...nfiguration/v1/tests/kubeletconfigs.machineconfiguration.openshift.io/KubeletConfigSpec.yaml
Show resolved
Hide resolved
|
/hold |
67d61bf to
aec4952
Compare
Please review |
payload-manifests/crds/0000_80_machine-config_01_kubeletconfigs.crd.yaml
Outdated
Show resolved
Hide resolved
| // When specified, the type field can be set to either "Old", "Intermediate", "Modern", "Custom" or omitted for backward compatibility. | ||
| // maximum minTLSVersion is VersionTLS13. | ||
| // +kubebuilder:validation:XValidation:rule="!has(self.type) || self.type == 'Old' || self.type == 'Intermediate' || self.type == 'Modern' || self.type == 'Custom'",message="only Old, Intermediate, Modern and Custom TLS profiles are supported for kubelet" |
There was a problem hiding this comment.
If you are allowing the type to be any of the types that are valid for the TLSSecurityProfile.Type field you probably don't need this validation - the type alias for that field already enforces an enum constraint with these same values.
There was a problem hiding this comment.
@everettraven Let's say there is a addition to TLSSecurityProfile.Type enum which kubelet doesn't support yet, then we need this validation right?
There was a problem hiding this comment.
In theory, yes. In practice, this is unlikely. Any changes to the TLSSecurityProfile API will need to go through the feature promotion process which will include ensuring that all components either support the changes or they have been explicitly updated to not handle them prior to the promotion of the field.
aec4952 to
41ea859
Compare
…PI doc and adds tests
41ea859 to
2dc542b
Compare
|
@ngopalak-redhat: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
This PR improves the documentation for the KubeletConfigSpec API to make it more accurate and user-friendly.
Fixes the doc: https://docs.redhat.com/en/documentation/openshift_container_platform/4.20/html/machine_apis/kubeletconfig-machineconfiguration-openshift-io-v1#spec-4
It also adds test coverage similar to the pattern established in #2370.
AutoSizingReserved will default to true from 4.21 onwards. The default value and the description was not documented until now.
Why is this a breaking change?
Test Coverage
Created test file: machineconfiguration/v1/tests/kubeletconfigs.machineconfiguration.openshift.io/KubeletConfigSpec.yaml